package com.d.client;

import com.d.client.dto.DingAppAccessTokenDto;
import com.d.client.dto.DingProcessInstanceResultDTO;
import com.d.client.dto.DingProcessInstanceWirteDTO;
import com.d.client.interceptor.DingInterceptor;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;

@BaseRequest(baseURL = "${dingUrl}", contentType = "application/json",
        charset = "UTF-8", interceptor = DingInterceptor.class)
public interface DingClient {

    /**
     * 获取token
     * @param appKey
     * @param appSecret
     * @return
     */
    @Request(url = "/oauth2/accessToken",type = "POST")
    DingAppAccessTokenDto getAppToken(@Body("appKey") String appKey, @Body("appSecret") String appSecret);

    /**
     * 获取钉钉审批模板列表
     * @param userId
     * @return
     */
    @Request(url = "workflow/processes/managements/templates",type = "GET")
    String getTemplatesList(@Query("userId") String userId);

    /**
     * 获取钉钉审批模板详情
     * @return
     */
    @Request(url = "/workflow/forms/schemas/processCodes",type = "GET")
    String getTemplatesDetail(@Query("processCode") String processCode);

    /**
     * 创建审批实例
     * @return
     */
    @Request(url = "/workflow/processInstances",type = "POST")
    DingProcessInstanceResultDTO createProcess(@Body DingProcessInstanceWirteDTO r);

}
